$.validator.setDefaults({
    submitHandler: function() {
      	var params = $(".form-div").serialize(); 
      	$.ajax( {  
                type : "POST",  
                url : serverIP+"/user/editPwd/save",  
                data : params,  
                xhrFields: {
	                withCredentials: true    // 设置sessionId相同
	            },
                success : function(data) {
                	if(data.code==0){
                		alert("修改密码成功，请重新登录");
                		window.location.href="login.html";
                	}else{
                		alert(data.msg);
                	}
                }    
            }); 
    }
});

$(document).ready(function() {
	$('.form-div').validate({
		rules: {
		 	oldPwd: "required",
		 	password: {
		 		required: true,
	        	minlength: 6	
		 	},
		 	confirm_password:{
		 		required: true,
		        minlength: 6,
		        equalTo: "#password"
		 	}
		},
		messages: {
	      	oldPwd: "请输入原来的密码",
	      	password: {
	       		required: "请输入新的密码",
        		minlength: "密码长度不能小于 6 个字母"
	      	},
	      	confirm_password: {
	        	required: "请输入新的密码",
		        minlength: "密码长度不能小于 6 个字母",
		        equalTo: "两次密码输入不一致"
	      	}
		}	
	})
	
})
$(".icon-ok").click(function() {
	$(".submit").click();
})
$(".reset").click(function() {
    $(".form-div").validate().resetForm();
    $(".form-div input").each(function(){
    	$(this).val("");
    	$(".btn-div input:last-child").val("提交");
    });
});



//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
}